package com.summer.utils;

import com.alibaba.fastjson.JSON;
import com.summer.entity.XcUser;
import org.springframework.security.core.context.SecurityContextHolder;

public class CurrentLoginUser {
    public static XcUser getLoginUser(){
        Object userJson = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        XcUser xcUser = null;
        if (userJson instanceof String){
            xcUser = JSON.parseObject(userJson.toString(), XcUser.class);
        }
        return xcUser;
    }
}
